#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod = 1e9 + 7;
ll n;
ll qpow(ll a, ll c) {
	ll ans1 = 1;
	while (c) {
		if (c % 2 == 1)
			ans1 = ans1 * a % mod;
		a = (a * a) % mod;
		c = c / 2;
	}
	return ans1;
}

void work() {
	cin >> n;

	ll ans = n * (n + 1) % mod * (2 * n + 1) % mod * qpow(6, mod - 2) % mod;

	ll ans_b = n * (n - 1) % mod * (2 * n - 1) % mod * qpow(6, mod - 2) % mod;

	ans = ((ans + ans_b) % mod + n * (n - 1) / 2) % mod;

	cout << ans * 2022 % mod << endl;

}


int main() {
	int T;
	cin >> T;
	while (T--) work();

	return 0;
}
